/* 
 * 杞欢涓哄悎鑲ユ敞鍒涚鎶€鍑哄搧锛屾湭缁忔巿鏉冭鍙笉寰椾娇鐢紒
 * 浣滆€咃細椋庝簯
 * 瀹樼綉锛歸ww.izhuchuang.com
 * 閭欢: 376621340@qq.com
 */
var lock = 0;
function msg(type){

                   layui.use('layer', function(){
                                var layer = layui.layer;
								
								layer.msg(type);});

}
function loading() {
	
    var boxHtml = '<div class="chuangbox"></div>';
    $(".chuangbox").css('top', '300px');
    if ($(".chuangbox").length == 0) {
        $("body").append(boxHtml);
    }
    $(".chuangbox").html('<img src="/public/admin/login/images/loading.gif" /><span  style=" color: blue;">正在加载中...</span>');
    $(".chuangbox").show();
    lock = 1;
}
function loadingnone() {
	
   
    $(".chuangbox").css('display','none');
   
}



function success(msg, timeout, callback) {
    var boxHtml = '<div class="chuangbox"></div>';
    if ($(".chuangbox").length == 0) {
        $("body").append(boxHtml);
    }
    $(".chuangbox").html('<img src="' + PUBLIC + '/images/right.gif" /><span  style=" color: green;">' + msg + '</span>');
    setTimeout(function () {
        lock = 0;
        $(".chuangbox").hide();
        eval(callback);
    }, timeout ? timeout : 3000);
}
function error(msg, timeout, callback) {
    var boxHtml = '<div class="chuangbox"></div>';
    if ($(".chuangbox").length == 0) {
        $("body").append(boxHtml);
    }
    $(".chuangbox").html('<img src="' + PUBLIC + '/images/wrong.gif" /><span  style=" color: red;">' + msg + '</span>');
    setTimeout(function () {
        lock = 0;
        $(".chuangbox").hide();
        eval(callback);
    }, timeout ? timeout : 3000);
}

function hidde() {
    $(".chuangbox").hide();
    lock = 0;
}

function jumpUrl(url) {
    if (url) {
        location.href = url;
    } else {
        history.back(-1);
    }
}

function yzmCode() { //鏇存崲楠岃瘉鐮�
    $(".yzm_code").click();
}

function dialog(title, content, width, height) {
	$('.theme-popover-mask').fadeIn(100);
    $(".theme-popover").html(content);
    $(".theme-popover").dialog({
        zIndex: 1000,
        width: width ? width : 300,
        height: height ? height : 200,
        modal: true
    });
	$('#ui-id-1').css("width",width);
	$('#ui-id-1').draggable();
	

}

function selectCallBack(id, name, v1, v2) {
    $("#" + id).val(v1);
    $("#" + name).val(v2);
	$('.theme-popover-mask').hide();
	$('.theme-popover').hide();
	$('.ui-dialog').hide();
	$('.ui-widget-header').hide();
	
	
	 hidde();
}


$(document).ready(function (e) {
    /*$(document).on("click", "input[type='submit']", function (e) {
        e.preventDefault();
        if (!lock) {
           // loading();
            if($(this).attr('rel')){
                $("#"+$(this).attr('rel')).submit();
            }else{
                $(this).parents('form').submit();    
            }
        }
    });*/
    $(".yzm_code").click(function () {
        $(this).find('img').attr('src', ROOT+'/index.php?g=home&m=verify&a=index&mt=' + Math.random());
    });

    $(document).on("click", "a[mini='act']", function (e) {
        e.preventDefault();
        if (!lock) {
            if (confirm("确认" + $(this).html())) {
                loading();
                $("#zhuchuang_frm").attr('src', $(this).attr('href'));
            }
        }
    });

    //鍏ㄩ€�
    $(document).on("click", ".checkAll", function (e) {
        var child = $(this).attr('rel');
        $(".child_" + child).prop('checked', $(this).prop("checked"));
    });


    $(document).on('click', "a[mini='list']", function (e) {
        e.preventDefault();
        if (!lock) {
            if (confirm("确认" + $(this).html())) {
                loading();
                $(this).parents('form').attr('action', $(this).attr('href')).submit();
            }
        }
    });


    $(document).on("click", "a[mini='load']", function (e) {

        e.preventDefault();
        if (!lock) {
            loading();
            var obj = $(this);
            $.get(obj.attr('href'), function (data) {
                if (data) {
                    dialog(obj.text(), data, obj.attr('w'), obj.attr('h'));

                }
               $('.theme-poptit .close').click(function(){
					$('.theme-popover-mask').fadeOut(100);
					$('.theme-popover').slideUp(200);
				});
				 hidde();
            }, 'html');

        }
    });
	
	
    $(document).on("click", "a[mini='select']", function (e) {
        e.preventDefault();
        if (!lock) {
            loading();
			
			$('.ui-dialog').show();
			$('.ui-widget-header').show();
            var obj = $(this);
            dialog(obj.text(), '<iframe id="select_frm" name="select_frm" src="' + obj.attr('href') + '" style="border:0px;width:' + (obj.attr('w') - 0) + 'px;height:' + (obj.attr('h') - 30) + 'px;"></iframe>', obj.attr('w'), obj.attr('h'));
            hidde();
        }
    });


    $(".searchG").click(function () {

        if ($(this).hasClass('searchGadd')) {
            $(this).removeClass("searchGadd");
        } else {
            $(this).addClass("searchGadd");
        }

        $(".selectNr2").slideToggle(200);
        $(".seleHidden").toggle(400);
    });
});

//娣诲姞鏍峰紡 
$(document).ready(function (e) {
	$("table.daemon_data  tr:odd").addClass("cred");
	$('table.daemon_data tr').mouseover(function(){
		$(this).addClass('over');
	}).mouseleave(function(){
		$(this).removeClass('over');
	});;
	
	$('table input.text').focus(function(){
 		 $(this).addClass('focus'); 
	  });
	  	$('table input.text').blur(function(){
 		 $(this).removeClass('focus'); 
	  });
	$('table select.text').focus(function(){
 		 $(this).addClass('focus'); 
	  });
	  	$('table select.text').blur(function(){
 		 $(this).removeClass('focus'); 
	  });
	  $('table textarea').focus(function(){
 		 $(this).addClass('focus'); 
	  });
	  	$('table textarea').blur(function(){
 		 $(this).removeClass('focus'); 
	  });
	  if($('.daemonPage').length > 0){
		  
		  if(!$('.daemonBot_cz').html() && $('.daemonPage').html().length<2){
				$('.daemonBot').css('display','none');
			  }
	  }
	  
});